$(function () {
    $('#save-order-btn').click(function (event) {
        event.preventDefault();
        var self = $(this);
        var dialog = $('#shipping-dialog');

        var num = $("input[name='num']").val();

        var submitType = self.attr("data-type");
        var order_id = self.attr('data-id');

        $.ajax({
            type: 'POST',
            url: '/manage/check_new_orders/',
            data: {
                'num':num,
                'order_id':order_id,
            },
            success: function (data) {
                dialog.modal('hide');
                if(data['code']==200){
                    window.location.reload()
                }else{
                    const timer =setInterval(() => {
                      zlalert.alertError(data['message']);
                      clearInterval(timer);

                    }, 100);
                }
            },
        });
    })
});



$(function () {
    $(".new-order-btn").click(function (event) {
        var self = $(this);
        var dialog = $('#shipping-dialog');
        dialog.modal('show');

        var tr = self.parent().parent();
        var savebtn = dialog.find("#save-order-btn");

        savebtn.attr("data-type",'update');
        savebtn.attr("data-id",tr.attr('data-id'));
    })
});
